﻿//using Commonality.Model.CPLCControl;
using Commonality.Model;
using Commonality.Model.PLCControl;

namespace Merge.Model
{

    public static class PLC
    {
        //public static CPLCControl cPLCControl1 ;
        //public  static CPLCControl cPLCControl3;
        //public  static CPLCControl cPLCControl4;
        //public  static CPLCControl cPLCControl5;
        //public  static CPLCControl cPLCControl6;
        //public  static CPLCControl cPLCControl7;
        //public static CPLCControl cPLCControl8;




        #region 主线
        private static ImplementLADEx PlcLoop;
        private static ImplementLADEx AutoLoop;
        private static event ImplementLADEx AutoLoopEvent;
        #endregion
        #region 标量
        /// <summary>
        /// 已经捕获状态
        /// </summary>
        public static short ScalarCapture = 100;

        /// <summary>
        /// 进入异常
        /// </summary>
        public static short ScalarAbnormal = 200;
        #endregion

        //站点1-主线区
        #region 站点1
        /// <summary>
        /// 分类区入口扫码触发
        /// </summary>
        public static TPLCCell dClassifyEntrance_SQRC_A;
        /// <summary>
        /// 分类区入口扫码触发
        /// </summary>
        public static TPLCCell dClassifyEntrance_SQRC_B;
        /// <summary>
        /// 分类区出口/回流线入口扫码触发
        /// </summary>
        public static TPLCCell dClassifyExit_SQRC;
        /// <summary>
        /// 回流线出口扫码触发
        /// </summary>
        public static TPLCCell dBackflowExit_SQRC;
        /// <summary>
        /// 人工作业入料口
        /// </summary>
        public static TPLCCell dManualWork_SQRC;

        /// <summary>
        /// 穴位节点1
        /// </summary>
        public static TPLCCell dCave1_A;
        /// <summary>
        /// 穴位节点1
        /// </summary>
        public static TPLCCell dCave1_B;
        /// <summary>
        /// 穴位节点2
        /// </summary>
        public static TPLCCell dCave2_A;
        /// <summary>
        /// 穴位节点2
        /// </summary>
        public static TPLCCell dCave2_B;
        /// <summary>
        /// 穴位节点3
        /// </summary>
        public static TPLCCell dCave3_A;
        /// <summary>
        /// 穴位节点3
        /// </summary>
        public static TPLCCell dCave3_B;

        /// <summary>
        /// 全线到位感应器
        /// </summary>
        public static TPLCCell dSensor;
        #endregion

        //站点3、4、5、6、7、8
        #region 穴位区
        #region 模组A1
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_A1;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_A1;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A11;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A12;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A13;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A14;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A15;

        public static TPLCCell dCaveStuation_A11;
        public static TPLCCell dCaveStuation_A12;
        public static TPLCCell dCaveStuation_A13;
        public static TPLCCell dCaveStuation_A14;
        public static TPLCCell dCaveStuation_A15;

        public static TPLCCell mAutoRuning_A1;
        public static TPLCCell mAutoRuning_A2;
        public static TPLCCell mAutoRuning_A3;
        public static TPLCCell mAutoRuning_B1;
        public static TPLCCell mAutoRuning_B2;
        public static TPLCCell mAutoRuning_B3;
        #endregion
        #region 模组A2
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_A2;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_A2;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A21;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A22;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A23;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A24;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A25;

        public static TPLCCell dCaveStuation_A21;
        public static TPLCCell dCaveStuation_A22;
        public static TPLCCell dCaveStuation_A23;
        public static TPLCCell dCaveStuation_A24;
        public static TPLCCell dCaveStuation_A25;
        #endregion
        #region 模组A3
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_A3;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_A3;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A31;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A32;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A33;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A34;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_A35;

        public static TPLCCell dCaveStuation_A31;
        public static TPLCCell dCaveStuation_A32;
        public static TPLCCell dCaveStuation_A33;
        public static TPLCCell dCaveStuation_A34;
        public static TPLCCell dCaveStuation_A35;


        #region 定时器
        public static TPLCCell tCaverA11OldTime;
        public static TPLCCell tCaverA12OldTime;
        public static TPLCCell tCaverA13OldTime;
        public static TPLCCell tCaverA14OldTime;
        public static TPLCCell tCaverA15OldTime;

        public static TPLCCell tCaverA21OldTime;
        public static TPLCCell tCaverA22OldTime;
        public static TPLCCell tCaverA23OldTime;
        public static TPLCCell tCaverA24OldTime;
        public static TPLCCell tCaverA25OldTime;

        public static TPLCCell tCaverA31OldTime;
        public static TPLCCell tCaverA32OldTime;
        public static TPLCCell tCaverA33OldTime;
        public static TPLCCell tCaverA34OldTime;
        public static TPLCCell tCaverA35OldTime;


        public static TPLCCell tCaverB11OldTime;
        public static TPLCCell tCaverB12OldTime;
        public static TPLCCell tCaverB13OldTime;
        public static TPLCCell tCaverB14OldTime;
        public static TPLCCell tCaverB15OldTime;

        public static TPLCCell tCaverB21OldTime;
        public static TPLCCell tCaverB22OldTime;
        public static TPLCCell tCaverB23OldTime;
        public static TPLCCell tCaverB24OldTime;
        public static TPLCCell tCaverB25OldTime;

        public static TPLCCell tCaverB31OldTime;
        public static TPLCCell tCaverB32OldTime;
        public static TPLCCell tCaverB33OldTime;
        public static TPLCCell tCaverB34OldTime;
        public static TPLCCell tCaverB35OldTime;
        #endregion
        #endregion

        #region 模组B1
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_B1;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_B1;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B11;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B12;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B13;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B14;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B15;

        public static TPLCCell dCaveStuation_B11;
        public static TPLCCell dCaveStuation_B12;
        public static TPLCCell dCaveStuation_B13;
        public static TPLCCell dCaveStuation_B14;
        public static TPLCCell dCaveStuation_B15;
        #endregion
        #region 模组B2
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_B2;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_B2;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B21;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B22;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B23;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B24;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B25;

        public static TPLCCell dCaveStuation_B21;
        public static TPLCCell dCaveStuation_B22;
        public static TPLCCell dCaveStuation_B23;
        public static TPLCCell dCaveStuation_B24;
        public static TPLCCell dCaveStuation_B25;
        #endregion
        #region 模组B3
        /// <summary>
        /// 放料目标
        /// </summary>
        public static TPLCCell dDestination_B3;
        /// <summary>
        /// 模组忙碌标志
        /// </summary>
        public static TPLCCell mHandBusy_B3;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B31;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B32;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B33;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B34;
        /// <summary>
        /// 穴位内存量
        /// </summary>
        public static TPLCCell dCaveStock_B35;

        public static TPLCCell dCaveStuation_B31;
        public static TPLCCell dCaveStuation_B32;
        public static TPLCCell dCaveStuation_B33;
        public static TPLCCell dCaveStuation_B34;
        public static TPLCCell dCaveStuation_B35;
        #endregion
        #endregion


        public static void InitPLCCell()
        {
            //站点1

            CPLCControl.InitPlcCell(out dClassifyEntrance_SQRC_A, ESignalType.SIG_D, 1, 0, 530);
            CPLCControl.InitPlcCell(out dClassifyEntrance_SQRC_B, ESignalType.SIG_D, 1, 0, 540);

            CPLCControl.InitPlcCell(out dClassifyExit_SQRC, ESignalType.SIG_D, 1, 0, 534);

            CPLCControl.InitPlcCell(out dBackflowExit_SQRC, ESignalType.SIG_D, 1, 0, 535);

            CPLCControl.InitPlcCell(out dManualWork_SQRC, ESignalType.SIG_D, 1, 0, 536);

            CPLCControl.InitPlcCell(out dCave1_A, ESignalType.SIG_D, 1, 0, 531);
            CPLCControl.InitPlcCell(out dCave2_A, ESignalType.SIG_D, 1, 0, 532);
            CPLCControl.InitPlcCell(out dCave3_A, ESignalType.SIG_D, 1, 0, 533);

            CPLCControl.InitPlcCell(out dCave1_B, ESignalType.SIG_D, 1, 0, 541);
            CPLCControl.InitPlcCell(out dCave2_B, ESignalType.SIG_D, 1, 0, 542);
            CPLCControl.InitPlcCell(out dCave3_B, ESignalType.SIG_D, 1, 0, 543);

            CPLCControl.InitPlcCell(out dSensor, ESignalType.SIG_D, 1, 0, 6);

            //站点3、4、5、6、7、8
            //
            CPLCControl.InitPlcCell(out dDestination_A1, ESignalType.SIG_D, 3, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_A1, ESignalType.SIG_M, 3, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_A11, ESignalType.SIG_D, 3, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_A12, ESignalType.SIG_D, 3, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_A13, ESignalType.SIG_D, 3, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_A14, ESignalType.SIG_D, 3, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_A15, ESignalType.SIG_D, 3, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_A11, ESignalType.SIG_D, 3, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_A12, ESignalType.SIG_D, 3, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_A13, ESignalType.SIG_D, 3, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_A14, ESignalType.SIG_D, 3, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_A15, ESignalType.SIG_D, 3, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_A1, ESignalType.SIG_M, 3, 0, 820);


            //

            CPLCControl.InitPlcCell(out dDestination_A2, ESignalType.SIG_D, 4, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_A2, ESignalType.SIG_M, 4, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_A21, ESignalType.SIG_D, 4, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_A22, ESignalType.SIG_D, 4, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_A23, ESignalType.SIG_D, 4, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_A24, ESignalType.SIG_D, 4, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_A25, ESignalType.SIG_D, 4, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_A21, ESignalType.SIG_D, 4, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_A22, ESignalType.SIG_D, 4, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_A23, ESignalType.SIG_D, 4, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_A24, ESignalType.SIG_D, 4, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_A25, ESignalType.SIG_D, 4, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_A2, ESignalType.SIG_M, 4, 0, 820);

            //
            CPLCControl.InitPlcCell(out dDestination_A3, ESignalType.SIG_D, 5, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_A3, ESignalType.SIG_M, 5, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_A31, ESignalType.SIG_D, 5, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_A32, ESignalType.SIG_D, 5, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_A33, ESignalType.SIG_D, 5, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_A34, ESignalType.SIG_D, 5, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_A35, ESignalType.SIG_D, 5, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_A31, ESignalType.SIG_D, 5, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_A32, ESignalType.SIG_D, 5, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_A33, ESignalType.SIG_D, 5, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_A34, ESignalType.SIG_D, 5, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_A35, ESignalType.SIG_D, 5, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_A3, ESignalType.SIG_M, 5, 0, 820);

            //
            CPLCControl.InitPlcCell(out dDestination_B1, ESignalType.SIG_D, 6, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_B1, ESignalType.SIG_M, 6, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_B11, ESignalType.SIG_D, 6, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_B12, ESignalType.SIG_D, 6, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_B13, ESignalType.SIG_D, 6, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_B14, ESignalType.SIG_D, 6, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_B15, ESignalType.SIG_D, 6, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_B11, ESignalType.SIG_D, 6, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_B12, ESignalType.SIG_D, 6, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_B13, ESignalType.SIG_D, 6, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_B14, ESignalType.SIG_D, 6, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_B15, ESignalType.SIG_D, 6, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_B1, ESignalType.SIG_M, 6, 0, 820);

            //
            CPLCControl.InitPlcCell(out dDestination_B2, ESignalType.SIG_D, 7, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_B2, ESignalType.SIG_M, 7, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_B21, ESignalType.SIG_D, 7, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_B22, ESignalType.SIG_D, 7, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_B23, ESignalType.SIG_D, 7, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_B24, ESignalType.SIG_D, 7, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_B25, ESignalType.SIG_D, 7, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_B21, ESignalType.SIG_D, 7, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_B22, ESignalType.SIG_D, 7, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_B23, ESignalType.SIG_D, 7, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_B24, ESignalType.SIG_D, 7, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_B25, ESignalType.SIG_D, 7, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_B2, ESignalType.SIG_M, 7, 0, 820);

            //
            CPLCControl.InitPlcCell(out dDestination_B3, ESignalType.SIG_D, 8, 0, 800);
            CPLCControl.InitPlcCell(out mHandBusy_B3, ESignalType.SIG_M, 8, 0, 800);
            CPLCControl.InitPlcCell(out dCaveStock_B31, ESignalType.SIG_D, 8, 0, 801);
            CPLCControl.InitPlcCell(out dCaveStock_B32, ESignalType.SIG_D, 8, 0, 802);
            CPLCControl.InitPlcCell(out dCaveStock_B33, ESignalType.SIG_D, 8, 0, 803);
            CPLCControl.InitPlcCell(out dCaveStock_B34, ESignalType.SIG_D, 8, 0, 804);
            CPLCControl.InitPlcCell(out dCaveStock_B35, ESignalType.SIG_D, 8, 0, 805);

            CPLCControl.InitPlcCell(out dCaveStuation_B31, ESignalType.SIG_D, 8, 0, 811);
            CPLCControl.InitPlcCell(out dCaveStuation_B32, ESignalType.SIG_D, 8, 0, 812);
            CPLCControl.InitPlcCell(out dCaveStuation_B33, ESignalType.SIG_D, 8, 0, 813);
            CPLCControl.InitPlcCell(out dCaveStuation_B34, ESignalType.SIG_D, 8, 0, 814);
            CPLCControl.InitPlcCell(out dCaveStuation_B35, ESignalType.SIG_D, 8, 0, 815);

            CPLCControl.InitPlcCell(out mAutoRuning_B3, ESignalType.SIG_M, 8, 0, 820);


            CPLCControl.InitPlcCell(out tCaverA11OldTime, ESignalType.SIG_T, 1, 1);
            CPLCControl.InitPlcCell(out tCaverA12OldTime, ESignalType.SIG_T, 1, 2);
            CPLCControl.InitPlcCell(out tCaverA13OldTime, ESignalType.SIG_T, 1, 3);
            CPLCControl.InitPlcCell(out tCaverA14OldTime, ESignalType.SIG_T, 1, 4);
            CPLCControl.InitPlcCell(out tCaverA15OldTime, ESignalType.SIG_T, 1, 5);

            CPLCControl.InitPlcCell(out tCaverA21OldTime, ESignalType.SIG_T, 2, 1);
            CPLCControl.InitPlcCell(out tCaverA22OldTime, ESignalType.SIG_T, 2, 2);
            CPLCControl.InitPlcCell(out tCaverA23OldTime, ESignalType.SIG_T, 2, 3);
            CPLCControl.InitPlcCell(out tCaverA24OldTime, ESignalType.SIG_T, 2, 4);
            CPLCControl.InitPlcCell(out tCaverA25OldTime, ESignalType.SIG_T, 2, 5);

            CPLCControl.InitPlcCell(out tCaverA31OldTime, ESignalType.SIG_T, 3, 1);
            CPLCControl.InitPlcCell(out tCaverA32OldTime, ESignalType.SIG_T, 3, 2);
            CPLCControl.InitPlcCell(out tCaverA33OldTime, ESignalType.SIG_T, 3, 3);
            CPLCControl.InitPlcCell(out tCaverA34OldTime, ESignalType.SIG_T, 3, 4);
            CPLCControl.InitPlcCell(out tCaverA35OldTime, ESignalType.SIG_T, 3, 5);


            CPLCControl.InitPlcCell(out tCaverB11OldTime, ESignalType.SIG_T, 4, 1);
            CPLCControl.InitPlcCell(out tCaverB12OldTime, ESignalType.SIG_T, 4, 2);
            CPLCControl.InitPlcCell(out tCaverB13OldTime, ESignalType.SIG_T, 4, 3);
            CPLCControl.InitPlcCell(out tCaverB14OldTime, ESignalType.SIG_T, 4, 4);
            CPLCControl.InitPlcCell(out tCaverB15OldTime, ESignalType.SIG_T, 4, 5);

            CPLCControl.InitPlcCell(out tCaverB21OldTime, ESignalType.SIG_T, 5, 1);
            CPLCControl.InitPlcCell(out tCaverB22OldTime, ESignalType.SIG_T, 5, 2);
            CPLCControl.InitPlcCell(out tCaverB23OldTime, ESignalType.SIG_T, 5, 3);
            CPLCControl.InitPlcCell(out tCaverB24OldTime, ESignalType.SIG_T, 5, 4);
            CPLCControl.InitPlcCell(out tCaverB25OldTime, ESignalType.SIG_T, 5, 5);

            CPLCControl.InitPlcCell(out tCaverB31OldTime, ESignalType.SIG_T, 6, 1);
            CPLCControl.InitPlcCell(out tCaverB32OldTime, ESignalType.SIG_T, 6, 2);
            CPLCControl.InitPlcCell(out tCaverB33OldTime, ESignalType.SIG_T, 6, 3);
            CPLCControl.InitPlcCell(out tCaverB34OldTime, ESignalType.SIG_T, 6, 4);
            CPLCControl.InitPlcCell(out tCaverB35OldTime, ESignalType.SIG_T, 6, 5);
        }
        public static void PLCInit(ImplementLADEx al)
        {
            CPLCControl.workstationFirstAddress = 1;
            CPLCControl.workstationNumOffset = 8;
            PlcLoop = new ImplementLADEx(PlcImplement);
            CPLCControl.SetLADProcessEx(PlcLoop);
            PLCOpen();
            if (al != null)
            {
                AutoLoop = new ImplementLADEx(al);
                AutoLoopEvent += AutoLoop;
            }


        }

        public static void PLCOpen()
        {
            Log4Net.MsgInfo("站点1-线体:" + CPLCControl.OpenPLC(1));

            Log4Net.MsgInfo("站点3-A1模组:" + CPLCControl.OpenPLC(3));
            Log4Net.MsgInfo("站点4-A2模组:" + CPLCControl.OpenPLC(4));
            Log4Net.MsgInfo("站点5-A3模组:" + CPLCControl.OpenPLC(5));
            Log4Net.MsgInfo("站点6-B1模组:" + CPLCControl.OpenPLC(6));
            Log4Net.MsgInfo("站点7-B2模组:" + CPLCControl.OpenPLC(7));
            Log4Net.MsgInfo("站点8-B3模组:" + CPLCControl.OpenPLC(8));
        }
        public static void PLCClose()
        {
            CPLCControl.ClosePLC(1);
            CPLCControl.ClosePLC(3);
            CPLCControl.ClosePLC(4);
            CPLCControl.ClosePLC(5);
            CPLCControl.ClosePLC(6);
            CPLCControl.ClosePLC(7);
            CPLCControl.ClosePLC(8);
        }
        private static void PlcImplement()
        {


            //
            try
            {
                AutoLoopEventFunction();
            }
            catch
            {
            }

        }
        private static void AutoLoopEventFunction()
        {
            if (AutoLoopEvent != null)
            {
                AutoLoopEvent();
            }
        }

    }

}
